﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

/// 本文件是界面实现的辅助类，仅包含非常少的GDMP API的演示内容

#include "OwnerPtr.h"

#include <QDialog>

class QBoxLayout;
class QTableView;
class QStandardItemModel;

namespace gcmp
{
    class IUserTransaction;
    class ILineTypeNew;
}

namespace Sample
{
    // 线样式选择对话框
    class LineTypeDlg : public QDialog
    {
        Q_OBJECT

    public:
        LineTypeDlg(QWidget *parent = nullptr);
        ~LineTypeDlg();

        public Q_SLOTS:
        void OnOK();
        void OnCancle();

    public:
        QString GetSelectLineTypeName() const { return m_selectLineTypeName; }

    private:
        void CreateTableView();
        void CreateButton();
        void onMoveRequested(const QPoint& cursorPos, const QPoint& offset);
        // 按线型名称进行排序
        void SortLineTypesByName(std::vector<gcmp::ILineTypeNew*>& arrLineTypes) const;
    private:
        QBoxLayout* m_dlgLayout;
        QTableView* m_tableView;
        QStandardItemModel* m_model;

        //QPushButton* m_okButton;

        // 选中的线型名称。
        QString m_selectLineTypeName;
        gcmp::OwnerPtr<gcmp::IUserTransaction>  m_opUserTransaction;
    };

}

